from update import update_user_profile
from update import update_recall
from update import update_video_profile
from update import update_video_similar
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.executors.pool import ProcessPoolExecutor
import pytz

timez = pytz.timezone('Asia/Shanghai')

# 编写定时运行配置
executors = {
    'default': ProcessPoolExecutor(3)
}

# if __name__ == '__main__':
#     # 创建scheduler，多进程执行
#     scheduler = BlockingScheduler(executors=executors, timezone=timez)
#     # scheduler = BlockingScheduler(executors=executors)
#
#     # 添加定时更新任务更新用户画像
#     scheduler.add_job(update_user_profile, trigger='interval', seconds=30)
#
#     # 定时任务更新文章画像
#     scheduler.add_job(update_video_profile, trigger='interval', seconds=30)
#
#     # 更新视频相似度
#     scheduler.add_job(update_video_similar, trigger='interval', seconds=30)
#
#     # 添加定时任务更新召回结果
#     scheduler.add_job(update_recall, trigger='interval', seconds=60)
#
#     # 开启任务
#     scheduler.start()


if __name__ == '__main__':
    # 更新视频相似度
    update_video_similar()


    # 更新用户画像
    update_user_profile()


